

$(document).ready(function() {
	
	//var url = basePath+"/dic/addDic";
	var url = basePath+"/role/addRole";
	
	if($("#roleId").val() != "" || $("#roleId").val() == null){
		//url = basePath+"/dic/editDic";
		url = basePath+"/role/editRole";
	}
	
	
	$(".form-horizontal").validate({
		rules:{
			roleName:{
				required:true,
				maxlength:30
			},
			roleDesc:{
				maxlength:100
			}
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit({
		        type:"post",
		        url:url,
		        async:false,
		        //beforeSubmit: showRequest,
		        success: function(data){
		        	 layer.msg(data.msg,{time:1000});
		        	 setTimeout(function(){
		        		 parent.location.reload();
		        		 var index = parent.layer.getFrameIndex(window.name);
			        	 parent.layer.close(index);
		        	 },1000)
		        	 
		        	
		        }
		      });
		}
	});
	
});
